package com.demo.aop.pcut.dyanmic;

import com.demo.aop.pcut.stat.SimpleAdvice;
import org.springframework.aop.Advisor;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;

/**
 * 描述：主类
 *
 * @author lida
 * @time 2019/10/23 14:47
 */
public class DynamicStaticPointcutDemo {

	public static void main(String[] args) {
		SimpleBean target = new SimpleBean();

		//将动态切入点和通知结合成Advisor
		Advisor advisor = new DefaultPointcutAdvisor(new DynamicSimplePointcut(), new SimpleAdvice());

		//代理
		ProxyFactory pf = new ProxyFactory(target);
		pf.addAdvisor(advisor);

		SimpleBean proxy = (SimpleBean) pf.getProxy();
		proxy.bar();
		proxy.foo(99);
		proxy.foo(101);
	}
}
